package cn.lastjune.util;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

@Component
public class EmailTool {

	@Autowired
	private JavaMailSender mailSender;

	public void send() throws MessagingException {
		final MimeMessage mailMessage = mailSender.createMimeMessage();
		final MimeMessageHelper messageHelper = new MimeMessageHelper(mailMessage, true, "utf-8");
		messageHelper.setTo("zhenyulu@hengtiansoft.com");
		messageHelper.setFrom("no-reply@hengtiansoft.com");
		messageHelper.setSubject("测试邮件");
		messageHelper.setText("<html><head></head><body><h1>hello!!chao.wang</h1></body></html>", true);
		mailSender.send(mailMessage);
	}
}
